package com.frkj.yuan.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import com.frkj.yuan.R;
/**
 * Created by ${wangjiang} on 2017/10/11.
 * 上传头像的对话框
 */

public class UploadPicDialog extends Dialog implements View.OnClickListener {
    private Context context;
    private OnUploadPicDialogClickListener listener;

    public UploadPicDialog(Context context, OnUploadPicDialogClickListener listener) {
        super(context, R.style.AddressDialog);
        this.context = context;
        this.listener = listener;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_upload_pic);
        Window window = getWindow();
        // 去掉标题栏
        // 去掉背景边框
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
        params.width = ViewGroup.LayoutParams.MATCH_PARENT;
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
        findViewById(R.id.btn_photo).setOnClickListener(this);
        findViewById(R.id.btn_picture).setOnClickListener(this);
        findViewById(R.id.btn_canacle).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_photo:
                if (listener != null) {
                    listener.onPhoto(this);
                }
                break;
            case R.id.btn_picture:
                if (listener != null) {
                    listener.onPicture(this);
                }
                break;
            case R.id.btn_canacle:
                if (listener != null) {
                    listener.onCancel(this);
                }
                break;

        }
    }
}
